package cate.game.farm.record;

import cate.game.play.proce.play.PlayPO;
import cate.game.role.Role;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

import java.util.List;

@NoteClass("最快通关记录")
public class FastPassRecord extends SinglePassRecord{

	@NoteField("通关时间")
	public long costTime;

	@NoteField("战力")
	public long power;

	@Override
	protected boolean needUpdate(Role role, List<PlayPO> plays) {
		if (costTime <= 0) {
			return true;
		}
		long totalTime = plays.stream().mapToLong(PlayPO::playTime).sum();
		if (totalTime < costTime) {
			return true;
		}
		return false;
	}

	@Override
	protected void doRecord(Role role, List<PlayPO> plays) {
		costTime = plays.stream().mapToLong(PlayPO::playTime).sum();
		power = plays.stream().mapToLong(a -> a.a.getTotalPower()).sum();
	}
}
